{% extends 'html.html' %}
{% load static %}
{% load i18n %}

{% block page-head %}
    <script type="text/javascript" src="{% url 'javascript-catalog' %}"></script>
	{% block head %}{% endblock %}
	<title>{% block title %}{% endblock %}</title>
{% endblock %}

{% block page-header %}
    <nav class="navbar navbar-light bg-light navbar-expand-md">
{#        <a class="navbar-brand" href="#"><img class="navbar-brand" src="{% static 'images/icon/logo_pic.png' %}" height="30"></a>#}
{#        <a class="navbar-brand" href="{% url 'buckets:bucket_view' %}">{% trans '地球大数据科学工程对象云存储' %}</a>#}
        <a class="navbar-brand" href="#"><img src="{% static 'images/logo/iHarbor-Logo.svg' %}" height="30"></a>
        <a class="navbar-brand" href="{% url 'buckets:bucket_view' %}">{% trans '对象存储服务' %}</a>
        <ul class="navbar-nav mr-auto"></ul>
            <ul class="nav navbar-nav">
                <li class="nav-item dropdown">
                    {% get_available_languages as LANGUAGES %}
                    <form action="{% url 'set_language' %}" method="post" id="id-language-switcher" hidden>
                        {% csrf_token %}
                    </form>
                    <a class="dropdown-toggle nav-link btn" data-toggle="dropdown" role="button" aria-haspopup="true"
                       aria-expanded="false">{% trans '语言' %}<span class="caret"></span></a>
                    <ul class="dropdown-menu" id="language-switcher">
                        {% for code, name in LANGUAGES %}
                            <li class="dropdown-item language-switcher-item" value="{{ code }}"><a class="nav-link"  href="#">{{ name }}</a></li>
                        {% endfor %}
                    </ul>
                </li>
                {% if share_user %}
                    <li class="nav-item"><a class="nav-link">{% blocktrans %}{{ share_user }} 的分享{% endblocktrans %}</a></li>
                {% endif %}
            </ul>
        </div>
    </nav>
{% endblock %}

{% block page-content %}
    {% block boby %}{% endblock %}
{% endblock %}

{% block page-script %}
    <script type="text/javascript" src="{% static 'iharbor/js/common.js' %}"></script>
    <script>
        $("#language-switcher").on("click", ".language-switcher-item", function () {
            let langValue = $(this).attr('value');
            let form = $("#id-language-switcher");
            let langInput = document.createElement("input");
            langInput.type="text";
            langInput.name="language";
            langInput.value = langValue;
            form.append(langInput);
            form.submit();
        })
    </script>
	{% block script %}{% endblock %}
{% endblock %}
